package io.renren.modules.weldingmachineinfo.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.welderinfo.entity.WelderinfoEntity;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import io.renren.modules.weldingmachineinfo.entity.WeldingmachineinfoEntity;
import io.renren.modules.weldingmachineinfo.service.WeldingmachineinfoService;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;



/**
 * 
 *
 * @author chenshun
 * @email sunlightcs@gmail.com
 * @date 2022-12-28 19:50:24
 */
@RestController
@RequestMapping("weldingmachineinfo/weldingmachineinfo")
public class WeldingmachineinfoController {
    @Autowired
    private WeldingmachineinfoService weldingmachineinfoService;

    @GetMapping("getwminfo")
    public List<WeldingmachineinfoEntity> getwminfo(@RequestParam(value = "wmId",required = false) String wmId, @RequestParam(value = "wmNote",required = false) String wmNote){
        return weldingmachineinfoService.getwminfo(wmId,wmNote);
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("weldingmachineinfo:weldingmachineinfo:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = weldingmachineinfoService.queryPage(params);

        return R.ok().put("page", page);
    }

    @GetMapping("getGwsn")
    public String getGwsn(@RequestParam(value = "wmId",required = false) String wmId){
        return weldingmachineinfoService.getGwsn(wmId);
    }





    /**
     * 信息
     */
    @RequestMapping("/info/{wmid}")
    @RequiresPermissions("weldingmachineinfo:weldingmachineinfo:info")
    public R info(@PathVariable("wmid") Integer wmid){
		WeldingmachineinfoEntity weldingmachineinfo = weldingmachineinfoService.getById(wmid);

        return R.ok().put("weldingmachineinfo", weldingmachineinfo);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("weldingmachineinfo:weldingmachineinfo:save")
    public R save(@RequestBody WeldingmachineinfoEntity weldingmachineinfo){
		weldingmachineinfoService.save(weldingmachineinfo);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("weldingmachineinfo:weldingmachineinfo:update")
    public R update(@RequestBody WeldingmachineinfoEntity weldingmachineinfo){
		weldingmachineinfoService.updateById(weldingmachineinfo);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("weldingmachineinfo:weldingmachineinfo:delete")
    public R delete(@RequestBody Integer[] wmids){
		weldingmachineinfoService.removeByIds(Arrays.asList(wmids));

        return R.ok();
    }

}
